// RPG Maker MZ project templates and data structures

export const getDefaultSystem = (gameTitle: string) => ({
  gameTitle,
  versionId: 1,
  locale: "ja_JP",
  partyMembers: [1],
  currencyUnit: "G",
  windowTone: [0, 0, 0, 0],
  attackMotions: [
    { type: 0, weaponImageId: 0 },
    { type: 1, weaponImageId: 1 },
    { type: 1, weaponImageId: 2 },
    { type: 1, weaponImageId: 3 },
    { type: 1, weaponImageId: 4 },
    { type: 1, weaponImageId: 5 },
    { type: 1, weaponImageId: 6 },
    { type: 2, weaponImageId: 7 },
    { type: 2, weaponImageId: 8 },
    { type: 2, weaponImageId: 9 },
    { type: 0, weaponImageId: 10 },
    { type: 0, weaponImageId: 11 },
    { type: 0, weaponImageId: 12 }
  ],
  battleBgm: { name: "Battle1", pan: 0, pitch: 100, volume: 90 },
  battleEndMe: { name: "Victory1", pan: 0, pitch: 100, volume: 90 },
  defeatMe: { name: "Defeat1", pan: 0, pitch: 100, volume: 90 },
  gameoverMe: { name: "Gameover1", pan: 0, pitch: 100, volume: 90 },
  titleBgm: { name: "Theme1", pan: 0, pitch: 100, volume: 90 },
  boat: { bgm: { name: "Ship1", pan: 0, pitch: 100, volume: 90 }, characterIndex: 0, characterName: "Vehicle", startMapId: 0, startX: 0, startY: 0 },
  ship: { bgm: { name: "Ship2", pan: 0, pitch: 100, volume: 90 }, characterIndex: 1, characterName: "Vehicle", startMapId: 0, startX: 0, startY: 0 },
  airship: { bgm: { name: "Ship3", pan: 0, pitch: 100, volume: 90 }, characterIndex: 2, characterName: "Vehicle", startMapId: 0, startX: 0, startY: 0 },
  title1Name: "Castle",
  title2Name: "",
  optDisplayTp: true,
  optDrawTitle: true,
  optTransparent: false,
  optFollowers: true,
  optSlipDeath: false,
  optFloorDeath: false,
  optSideView: false,
  optExtraExp: false,
  titleCommandWindow: { background: 0, offsetX: 0, offsetY: 0 },
  startMapId: 1,
  startX: 0,
  startY: 0,
  terms: {
    basic: ["レベル", "Lv", "HP", "HP", "MP", "MP", "TP", "TP", "EXP", "EXP"],
    commands: ["戦う", "逃げる", "攻撃", "防御", "アイテム", "スキル", "装備", "ステータス", "並び替え", "セーブ", "ゲーム終了", "オプション", "武器", "防具", "大事なもの", "装備", "最強装備", "全て外す", "ニューゲーム", "コンティニュー", null, "タイトルへ", "やめる"],
    params: ["最大HP", "最大MP", "攻撃力", "防御力", "魔法力", "魔法防御", "敏捷性", "運"],
    messages: {
      actionFailure: "しかし %1 には効かなかった！",
      actorDamage: "%1 は %2 のダメージを受けた！",
      actorDrain: "%1 は %2 の %3 を奪った！",
      actorGain: "%1 の %2 が %3 上がった！",
      actorLoss: "%1 の %2 が %3 下がった！",
      actorNoDamage: "%1 はダメージを受けていない！",
      actorNoHit: "ミス！ %1 はダメージを受けていない！",
      actorRecovery: "%1 の %2 が %3 回復した！",
      alwaysDash: "常時ダッシュ",
      bgmVolume: "BGM 音量",
      bgsVolume: "BGS 音量",
      buffAdd: "%1 の %2 が上がった！",
      buffRemove: "%1 の %2 が元に戻った！",
      commandRemember: "コマンド記憶",
      counterAttack: "%1 の反撃！",
      criticalToActor: "痛恨の一撃！",
      criticalToEnemy: "会心の一撃！",
      debuffAdd: "%1 の %2 が下がった！",
      defeat: "%1 は倒れた。",
      emerge: "%1 が出現！",
      enemyDamage: "%1 に %2 のダメージを与えた！",
      enemyDrain: "%1 の %2 を %3 奪った！",
      enemyGain: "%1 の %2 が %3 上がった！",
      enemyLoss: "%1 の %2 が %3 下がった！",
      enemyNoDamage: "%1 にダメージを与えられない！",
      enemyNoHit: "ミス！ %1 にダメージを与えられない！",
      enemyRecovery: "%1 の %2 が %3 回復した！",
      escapeFailure: "しかし逃げることはできなかった！",
      escapeStart: "%1 は逃げ出した！",
      evasion: "%1 は攻撃をかわした！",
      expNext: "次の %1 まで",
      expTotal: "現在の %1",
      file: "ファイル",
      levelUp: "%1 は %2 %3 に上がった！",
      loadMessage: "どのファイルをロードしますか？",
      magicEvasion: "%1 は魔法を打ち消した！",
      magicReflection: "%1 は魔法を跳ね返した！",
      meVolume: "ME 音量",
      message: "文章速度",
      obtainExp: "%1 の %2 を獲得！",
      obtainGold: "お金を %1\\G 手に入れた！",
      obtainItem: "%1 を手に入れた！",
      obtainSkill: "%1 を覚えた！",
      partyName: "%1 たち",
      possession: "持っている数",
      preemptive: "%1 は先手を取った！",
      saveMessage: "どのファイルにセーブしますか？",
      seVolume: "SE 音量",
      substitute: "%1 が %2 をかばった！",
      surprise: "%1 は不意をつかれた！",
      useItem: "%1 は %2 を使った！",
      victory: "%1 の勝利！"
    }
  },
  testBattlers: [],
  testTroopId: 1,
  battleback1Name: "",
  battleback2Name: "",
  battlerName: "",
  battlerHue: 0,
  editMapId: 1,
  menuCommands: [true, true, true, true, true, true],
  skillTypes: ["", "魔法", "必殺技"],
  weaponTypes: ["", "短剣", "剣", "フレイル", "斧", "ムチ", "杖", "弓", "クロスボウ", "銃", "爪", "グローブ", "槍"],
  armorTypes: ["", "汎用", "魔法防具", "軽装鎧", "重装鎧", "小型盾", "大型盾"],
  equipTypes: ["武器", "盾", "頭", "身体", "装飾品"],
  elements: ["", "物理", "炎", "氷", "雷", "水", "土", "風", "光", "闇"],
  switches: [""],
  variables: [""],
  magicSkills: [1],
  advanced: {
    gameId: Math.floor(Math.random() * 100000000),
    screenWidth: 816,
    screenHeight: 624,
    uiAreaWidth: 816,
    uiAreaHeight: 624
  }
});

export const getDefaultMapInfo = (id: number, name: string) => ({
  id,
  expanded: false,
  name,
  order: id,
  parentId: 0,
  scrollX: 0,
  scrollY: 0
});

export const getDefaultMap = (id: number, name: string, width = 17, height = 13) => ({
  autoplayBgm: false,
  autoplayBgs: false,
  battleback1Name: "",
  battleback2Name: "",
  bgm: { name: "", pan: 0, pitch: 100, volume: 90 },
  bgs: { name: "", pan: 0, pitch: 100, volume: 90 },
  disableDashing: false,
  displayName: name,
  encounterList: [],
  encounterStep: 30,
  height,
  width,
  note: "",
  parallaxLoopX: false,
  parallaxLoopY: false,
  parallaxName: "",
  parallaxShow: true,
  parallaxSx: 0,
  parallaxSy: 0,
  scrollType: 0,
  specifyBattleback: false,
  tilesetId: 1,
  data: new Array(width * height * 6).fill(0),
  events: [null]
});

export const getDefaultEvent = (id: number, name: string, x: number, y: number) => ({
  id,
  name,
  note: "",
  pages: [{
    conditions: {
      actorId: 1,
      actorValid: false,
      itemId: 1,
      itemValid: false,
      selfSwitchCh: "A",
      selfSwitchValid: false,
      switch1Id: 1,
      switch1Valid: false,
      switch2Id: 1,
      switch2Valid: false,
      variableId: 1,
      variableValid: false,
      variableValue: 0
    },
    directionFix: false,
    image: {
      characterIndex: 0,
      characterName: "",
      direction: 2,
      pattern: 1,
      tileId: 0
    },
    list: [{ code: 0, indent: 0, parameters: [] }],
    moveFrequency: 3,
    moveRoute: {
      list: [{ code: 0, parameters: [] }],
      repeat: true,
      skippable: false,
      wait: false
    },
    moveSpeed: 3,
    moveType: 0,
    priorityType: 0,
    stepAnime: false,
    through: false,
    trigger: 0,
    walkAnime: true
  }],
  x,
  y
});

export const getDefaultActor = (id: number, name: string) => ({
  id,
  battlerName: "",
  characterIndex: 0,
  characterName: "Actor1",
  classId: 1,
  equips: [1, 1, 2, 3, 0],
  faceIndex: 0,
  faceName: "Actor1",
  traits: [],
  initialLevel: 1,
  maxLevel: 99,
  name,
  nickname: "",
  note: "",
  profile: ""
});

export const getDefaultClass = (id: number, name: string) => ({
  id,
  name,
  expParams: [30, 20, 30, 30],
  traits: [{
    code: 51,
    dataId: 1,
    value: 1
  }],
  learnings: [{
    level: 1,
    note: "",
    skillId: 1
  }],
  note: "",
  params: [
    [500, 800, 1000, 1200, 1500, 2000, 2500, 3000, 3500, 4000],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],
    [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],
    [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],
    [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],
    [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],
    [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]
  ]
});

export const getDefaultSkill = (id: number, name: string) => ({
  id,
  animationId: -1,
  damage: { critical: false, elementId: 0, formula: "0", type: 0, variance: 20 },
  description: "",
  effects: [],
  hitType: 0,
  iconIndex: 0,
  message1: "",
  message2: "",
  mpCost: 0,
  name,
  note: "",
  occasion: 0,
  repeats: 1,
  requiredWtypeId1: 0,
  requiredWtypeId2: 0,
  scope: 0,
  speed: 0,
  stypeId: 0,
  successRate: 100,
  tpCost: 0,
  tpGain: 0
});

export const getDefaultItem = (id: number, name: string) => ({
  id,
  animationId: -1,
  consumable: true,
  damage: { critical: false, elementId: 0, formula: "0", type: 0, variance: 20 },
  description: "",
  effects: [],
  hitType: 0,
  iconIndex: 0,
  itypeId: 1,
  name,
  note: "",
  occasion: 0,
  price: 0,
  repeats: 1,
  scope: 0,
  speed: 0,
  successRate: 100,
  tpGain: 0
});

export const getDefaultProjectStructure = () => ({
  audio: {
    bgm: [],
    bgs: [],
    me: [],
    se: []
  },
  data: {},
  effects: [],
  img: {
    animations: [],
    battlebacks1: [],
    battlebacks2: [],
    characters: [],
    enemies: [],
    faces: [],
    parallaxes: [],
    pictures: [],
    sv_actors: [],
    sv_enemies: [],
    system: [],
    tilesets: [],
    titles1: [],
    titles2: []
  },
  js: {
    plugins: []
  },
  movies: []
});